{ "cells": [ { "cell_type": "markdown", "id": "ecd6fd2c", "metadata": { "editable": true, "slideshow": { "slide_type": "slide" }, "tags": [] }, "source": [ "# Docker commands\n", "\n", "## Description of docker commands" ] }, { "cell_type": "markdown", "id": "5302512f", "metadata": { "editable": true, "jp-MarkdownHeadingCollapsed": true, "slideshow": { "slide_type": "subslide" }, "tags": [] }, "source": [ "### docker pull\n", "\n", "- The command to pull the image from docker repository.\n", "\n", "example:\n", "```bash\n", "foo@bar:$ docker pull python\n", "```\n" ] }, { "cell_type": "markdown", "id": "a549ba2f", "metadata": { "editable": true, "slideshow": { "slide_type": "subslide" }, "tags": [] }, "source": [ "### docker images\n", "List all the images in current docker daemon\n", "\n", "example:\n", "```bash\n", "foo@bar:$ docker images\n", "```\n" ] }, { "cell_type": "markdown", "id": "25ed7b44", "metadata": { "editable": true, "slideshow": { "slide_type": "subslide" }, "tags": [] }, "source": [ "### docker ps\n", "List all the containers currently executing in the docker daemon \n", "\n", "example:\n", "```bash\n", "foo@bar:$ docker ps\n", "foo@bar:$ docker ps -a\n", "```\n" ] }, { "cell_type": "markdown", "id": "3a5b2e0c", "metadata": { "editable": true, "slideshow": { "slide_type": "subslide" }, "tags": [] }, "source": [ "### docker rmi\n", "Delete the selected images\n", "\n", "example:\n", "```bash\n", "foo@bar:$ docker rmi \n", "```\n" ] }, { "cell_type": "markdown", "id": "9875ebfb", "metadata": { "editable": true, "slideshow": { "slide_type": "subslide" }, "tags": [] }, "source": [ "### docker start\n", "Start one or more stopped containers\n", "\n", "example:\n", "```bash\n", "foo@bar:$ docker start \n", "```\n" ] }, { "cell_type": "markdown", "id": "cc850cad", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### docker stop\n", "Stop one or more currently running containers\n", "\n", "example:\n", "```bash\n", "foo@bar:$ docker stop \n", "```" ] }, { "cell_type": "markdown", "id": "0a5090a9", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### docker inspect\n", "Return low-level information on Docker objects\n", "\n", "example:\n", "```bash\n", "foo@bar:$ docker inspect \n", "```\n" ] }, { "cell_type": "markdown", "id": "daa0c6c0", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### docker stop\n", "Stop one or more currently running containers\n", "\n", "example:\n", "```bash\n", "foo@bar:$ docker stop \n", "```\n" ] }, { "cell_type": "markdown", "id": "ee762f24", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "### docker prune\n", "\n", "Remove all stopped containers\n", "\n", "example:\n", "```bash\n", "foo@bar:$ docker docker container prune\n", "```\n" ] }, { "cell_type": "markdown", "id": "8424da1f-62d2-4b58-b3d2-1c527b7df201", "metadata": { "editable": true, "slideshow": { "slide_type": "slide" }, "tags": [] }, "source": [ "## Deploy the local docker registry\n", "\n", "- Run a local registry:\n", "\n", "`docker run -d -p 5000:5000 --restart=always --name registry registry:2`\n", "\n", "- Copy an image from Docker Hub to your registry\n", "- Pull the ubuntu:16.04 image from Docker Hub.\n", " \n", "`docker pull ubuntu:16.04`" ] }, { "cell_type": "markdown", "id": "be857821-cc13-44d4-b522-e8faf87f36c6", "metadata": { "editable": true, "slideshow": { "slide_type": "subslide" }, "tags": [] }, "source": [ "- Tag the image as `localhost:5000/my-ubuntu`\n", "\n", "- This creates an additional tag for the existing image.\n", "- When the first part of the tag is a hostname and port, Docker interprets this as the location of a registry, when pushing.\n", "\n", "`docker tag ubuntu:16.04 localhost:5000/my-ubuntu`" ] }, { "cell_type": "markdown", "id": "97f240ff-1948-445d-a46c-a091bbf5e095", "metadata": { "editable": true, "slideshow": { "slide_type": "subslide" }, "tags": [] }, "source": [ "- Push the image to the local registry running at localhost:5000:\n", "\n", "`docker push localhost:5000/my-ubuntu`\n", "\n", "- Remove the locally-cached ubuntu:16.04 and localhost:5000/my-ubuntu images\n", "\n", "`docker image remove ubuntu:16.04`\n", "\n", "`docker image remove localhost:5000/my-ubuntu`" ] }, { "cell_type": "markdown", "id": "8b5d8d00-324b-4ca3-8821-be810f4da9d7", "metadata": { "editable": true, "slideshow": { "slide_type": "subslide" }, "tags": [] }, "source": [ "- Stop a local registry\n", "\n", "`docker container stop registry`\n", "\n", "- To remove the container, use docker container rm.\n", " \n", "`docker container stop registry && docker container rm -v registry`" ] } ], "metadata": { "celltoolbar": "Slideshow", "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.10" } }, "nbformat": 4, "nbformat_minor": 5 }